package com.aiiter.web.controller.house;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aiiter.common.annotation.Log;
import com.aiiter.common.core.controller.BaseController;
import com.aiiter.common.core.domain.AjaxResult;
import com.aiiter.common.enums.BusinessType;
import com.aiiter.house.domain.HouseChargeItem;
import com.aiiter.house.service.IHouseChargeItemService;
import com.aiiter.common.utils.poi.ExcelUtil;
import com.aiiter.common.core.page.TableDataInfo;

/**
 * 存储与房产相关的收费条目信息Controller
 * 
 * @author yaocheng
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/house/chargeItem")
public class HouseChargeItemController extends BaseController
{
    @Autowired
    private IHouseChargeItemService houseChargeItemService;

    /**
     * 查询存储与房产相关的收费条目信息列表
     */
    @PreAuthorize("@ss.hasPermi('house:chargeItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(HouseChargeItem houseChargeItem)
    {
        startPage();
        List<HouseChargeItem> list = houseChargeItemService.selectHouseChargeItemList(houseChargeItem);
        return getDataTable(list);
    }

    /**
     * 导出存储与房产相关的收费条目信息列表
     */
    @PreAuthorize("@ss.hasPermi('house:chargeItem:export')")
    @Log(title = "存储与房产相关的收费条目信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HouseChargeItem houseChargeItem)
    {
        List<HouseChargeItem> list = houseChargeItemService.selectHouseChargeItemList(houseChargeItem);
        ExcelUtil<HouseChargeItem> util = new ExcelUtil<HouseChargeItem>(HouseChargeItem.class);
        util.exportExcel(response, list, "存储与房产相关的收费条目信息数据");
    }

    /**
     * 获取存储与房产相关的收费条目信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('house:chargeItem:query')")
    @GetMapping(value = "/{feeId}")
    public AjaxResult getInfo(@PathVariable("feeId") Long feeId)
    {
        return success(houseChargeItemService.selectHouseChargeItemByFeeId(feeId));
    }

    /**
     * 新增存储与房产相关的收费条目信息
     */
    @PreAuthorize("@ss.hasPermi('house:chargeItem:add')")
    @Log(title = "存储与房产相关的收费条目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseChargeItem houseChargeItem)
    {
        return toAjax(houseChargeItemService.insertHouseChargeItem(houseChargeItem));
    }

    /**
     * 修改存储与房产相关的收费条目信息
     */
    @PreAuthorize("@ss.hasPermi('house:chargeItem:edit')")
    @Log(title = "存储与房产相关的收费条目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseChargeItem houseChargeItem)
    {
        return toAjax(houseChargeItemService.updateHouseChargeItem(houseChargeItem));
    }

    /**
     * 删除存储与房产相关的收费条目信息
     */
    @PreAuthorize("@ss.hasPermi('house:chargeItem:remove')")
    @Log(title = "存储与房产相关的收费条目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{feeIds}")
    public AjaxResult remove(@PathVariable Long[] feeIds)
    {
        return toAjax(houseChargeItemService.deleteHouseChargeItemByFeeIds(feeIds));
    }
}
